package com.baizhi.webController;

import com.baizhi.entrty.Article;
import com.baizhi.entrty.ArticleDTO;
import com.baizhi.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("appArticle")
public class ArticleWebController {

    @Autowired
    private ArticleService as;

    @GetMapping("showAll")
    public List<ArticleDTO> showAll(){
       List<ArticleDTO> articles = as.showAll();
        return articles;
    }

    @GetMapping("showArticle")
    public List<Article> showArticle(){
        List<Article> showArticle =  as.showArticle();
        return showArticle;
    }

    @GetMapping("getArticleDto/{userId}")
    public List<ArticleDTO> getArticleDto(@PathVariable("userId") int userId){

        return as.getArticleDto(userId);
    }
}
